import 'package:flutter/material.dart';

class AnimatedExample01Page extends StatefulWidget {
  const AnimatedExample01Page({super.key});

  @override
  State<AnimatedExample01Page> createState() => _AnimatedExample01PageState();
}

class _AnimatedExample01PageState extends State<AnimatedExample01Page> {
  bool flag = true;

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        Scaffold(
          appBar: AppBar(
            title: const Text('Animated Example 01'),
          ),
          body: Stack(
            children: [
              ListView(
                children: const [
                  ListTile(
                    title: Text('我是一个列表'),
                  ),
                ],
              ),
            ],
          ),
          floatingActionButton: FloatingActionButton(
            onPressed: () {
              setState(() {
                flag = !flag;
              });
            },
            child: const Icon(Icons.add),
          ),
        ),
        Positioned(
          left: 0,
          top: 0,
          bottom: 0,
          child: AnimatedContainer(
            duration: const Duration(seconds: 1),
            width: 200,
            height: double.infinity,
            color: Colors.yellow,
            transform: flag
                ? Matrix4.translationValues(-200, 0, 0)
                : Matrix4.translationValues(0, 0, 0),
          ),
        ),
      ],
    );
  }
}
